﻿using Infrastructure.AggregateBase;
using Infrastructure.Error;
using System;
using System.Collections.Generic;
using System.ComponentModel.DataAnnotations;
using System.ComponentModel.DataAnnotations.Schema;
using System.Text;

namespace Domain.Model
{
    [Table("Wallet")]
    public class WalletAggregate : AggregateRoot<WalletAggregate, int>
    {
        [Key]
        [DatabaseGeneratedAttribute(DatabaseGeneratedOption.Identity)]
        public override int ID { get; set; }

        public int UserID { get; set; }
        /// <summary>
        /// 佣金收入钱包
        /// </summary>
        public int InComeBlance { get; set; }
        /// <summary>
        /// 冲值钱包
        /// </summary>
        public int ChargeBlance { get; set; }
        /// <summary>
        /// 保证金
        /// </summary>
        public int MarginBlance { get; set; }
        /// <summary>
        /// 支付宝账号
        /// </summary>
        [StringLength(50)]
        public string AliPayAccount { get; set; }
        /// <summary>
        /// 微信账号
        /// </summary>
        [StringLength(50)]
        public string WxPayAccount { get; set; }

        [Timestamp]
        public byte[] Version { get; set; }
        [StringLength(50)]
        public string AliPayAccountName { get;  set; }
        public string WxPayAccountName { get; set; }
        /// <summary>
        /// 是否足够余额
        /// </summary>
        /// <param name="fee"></param>
        /// <returns>大于0 需要冲值</returns>
        public int ChargeNeedPay(int fee)
        {
            return fee - ChargeBlance;
        }
    }
}
